bs=$1
threads_num=$2
saved_model_path="/mnt/workspace/datasets/yolov5m/yolov5mu.torchscript"
mhlo_mlir=yolov5m_bs${bs}.affine_libcall.mhlo.mlir
vmfb=yolov5m_bs${bs}.affine_libcall.hggc.vmfb
# entry_function、input和batch_size信息从模型制品库中的txt文件中获取
entry_function=forward
input=${bs}x3x640x640xf16
batch_size=${bs}
benchmark_out=yolov5m_bs${bs}.affine_libcall.bm.json

echo benchmark_out=${benchmark_out},input=${input}

# 1. import
iree-import-torch ${saved_model_path} -o ${mhlo_mlir} --input ${input}

# 2. compile
holmes-compile ${mhlo_mlir} --iree-input-type=mhlo --iree-hal-target-backends=hggc --mlir-disable-threading --mlir-elide-elementsattrs-if-larger=10 --iree-hal-cuda-llvm-target-arch=sm_80 --iree-mlir-to-vm-bytecode-module --holmes-dump-dispatch-info --iree-flow-dump-dispatch-graph --holmes-enable-mark-linalg-op-as-library-call --holmes-enable-corert-conversion --holmes-enable-batchnorm-fusion --holmes-flow-form-dispatch-fragmentary-region --holmes-enable-mhlo-layernorm-fusion=false --holmes-enable-multi-matmul-fusion --holmes-libcall-use-cutlass=true --holmes-flow-demote-f32-to-f16  -o ${vmfb}

# 3. run
holmes-benchmark-module --module_file=${vmfb} --device=cuda --entry_function=${entry_function} --function_input=${input} --batch_size=${batch_size} --enable_multi_stream=true --use_spin_wait=true --benchmark_repetitions=1 --benchmark_out=${benchmark_out} --benchmark_out_format=json --multi_thread ${threads_num}
python ./acc.py
echo 'run end'